import { defineConfig } from '@vben/vite-config';

import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import';

export default defineConfig(async () => {
  return {
    application: {},
    vite: {
      plugins: [
        Components({
          resolvers: [
            AntDesignVueResolver({
              importStyle: false, // css in js
            }),
          ],
        }),
        lazyImport({
          resolvers: [
            VxeResolver({
              libraryName: 'vxe-table',
            }),
            VxeResolver({
              libraryName: 'vxe-pc-ui',
            }),
          ],
        }),
      ],
      server: {
        proxy: {
          '/ai': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/ai/, ''),
            // mock代理目标地址
            target: 'https://ark.cn-beijing.volces.com/api/v3',
            ws: true,
          },
          '/api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''),
            // mock代理目标地址
            // target: 'http://192.168.2.153:8090', //胡
            // target: 'http://192.168.2.107:8090', // 郭
            // target: 'http://192.168.2.130:8090/', //宋
            // target: 'http://192.168.2.166:8090/', //召霞
            target: 'http://43.138.122.70:9051/', // 线上
            ws: true,
          },
        },
      },
    },
  };
});
